<template>
  <div class="main-container" id="main-container">
    <div class="main-container-inner">
      <div class="main-content">
        <!--<div class="breadcrumbs" id="breadcrumbs">
          <ul class="breadcrumb">
            <li>
              首页
            </li>
            <li>排选课</li>
            <li class="active">排课任务</li>
          </ul>
        </div>-->
        <div class="page-content">
          <div class="row">
            <div class="col-xs-12">
              <div class="main-title">
                <h3>排课任务</h3>
              </div>
              
              <div class="course-scheduling-base" v-loading.fullscreen.lock="fullscreenLoading">
                <div class="procedure">
                  <span @click="change" inx="0">
                    <router-link :class="{'disabled' : checked != 0}" :to="{ path: '/BaseSetting/teachTime' }">
                      <i>1</i>基本信息设置
                    </router-link>
                  </span>
                  <span class="gap">
                    <i></i>
                    <i></i>
                    <i></i>
                    <i></i>
                    <i></i>
                  </span>
                  <span @click="change" inx="1">
                    <a href="javascript:void(0)" :class="{'disabled' : checked != 1}">
                      <i>2</i>排课规则设置
                    </a>
                  </span>
                  <span class="gap">
                    <i></i>
                    <i></i>
                    <i></i>
                    <i></i>
                    <i></i>
                  </span>
                  <span @click="change" inx="2">
                    <a href="javascript:void(0)" :class="{'disabled' : checked != 2}">
                      <i>3</i>自动排课
                    </a>
                  </span>
                </div>
              </div>
              <router-view :tnId="schoolId"></router-view>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import utils from '@/assets/js/urlConfig.js'
export default {
  data() {
    return {
      items: [
        {
          icon: 'el-icon-setting',
          index: 'newsMsg',
          title: '新闻消息'
        },
        {
          icon: 'el-icon-star-on',
          index: 'noticeMsg',
          title: '通知消息'
        },
        {
          icon: 'el-icon-upload2',
          index: 'activityMsg',
          title: '活动消息'
        }
      ],
      checked: sessionStorage.getItem('sideBar') || 0,
      taskId: sessionStorage.getItem('taskId') || 91, 
      fullscreenLoading: false,
      schoolId:-1,
    }
  },
  computed: {
    onRoutes() {
      return this.$route.path.replace('/', '');
    }
  },
  updated() {
    this.checked = sessionStorage.getItem('sideBar') || 0;
  },
  created(){
    this.$http.get(utils.UrlConfig.getTokenValue)
        .then(res => {
          this.schoolId = res.data.bizData.tnId;
        })
  },
  methods: {
    change(e) {
      const next = e.currentTarget.getAttribute('inx');
      this.checked
      if (this.checked == 0 && next != 0) {
        this.fullscreenLoading = true;
         // 判断基础信息设置填写的完整性
        this.$http.get(utils.UrlConfig.CheckComplete + "&taskId=" +this.taskId)
          .then(res => {
            this.fullscreenLoading = false;
            if(res.data.rtnCode == '0000000') {
              this.checked = next;
              // sessionStorage.setItem('sideBar', next);
              if(next == 1) {
                location.hash = '/CourseRules/ScheduleTime';
              }else if(next == 2) {
                location.hash = '/automatic';
              }
            }else{
              this.$message.error(res.data.msg);
              return;
            }
          }).catch(error => {
          })
      }else{
        this.checked = next;
        if(next == 1) {
          location.hash = '/CourseRules/ScheduleTime';
        }else if(next == 2) {
          location.hash = '/automatic';
        }
      }
      sessionStorage.setItem('courseInx', 0);
      // sessionStorage.setItem('sideBar', this.checked);
    }
  }
}
</script>

<style>

</style>
